package proxy.cglib.service.impl;

import org.aopalliance.intercept.MethodInvocation;
import org.springframework.cglib.proxy.MethodInterceptor;
import org.springframework.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

public class CglibInterceptor implements MethodInterceptor {

  /**
   *
   * @param o
   * @param method
   * @param objects
   * @param methodProxy
   * @return
   * @throws Throwable
   */
  @Override
  public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
    System.out.println("Before Method Invoke");
    methodProxy.invokeSuper(o,objects);
    System.out.println("After Method Invoke");
    return o;
  }
}
